2900 #define SEG_KCODE 1  // kernel code
2901 #define SEG_KDATA 2  // kernel data+stack
2902 #define SEG_KCPU  3  // kernel per-cpu data
2903 
2904   # vectors.S sends all traps here.
2905 .globl alltraps
2906 alltraps:
2907   # Build trap frame.
2908   pushl %ds
2909   pushl %es
2910   pushl %fs
2911   pushl %gs
2912   pushal
2913 
2914   # Set up data and per-cpu segments.
2915   movw $(SEG_KDATA<<3), %ax
2916   movw %ax, %ds
2917   movw %ax, %es
2918   movw $(SEG_KCPU<<3), %ax
2919   movw %ax, %fs
2920   movw %ax, %gs
2921 
2922   # Call trap(tf), where tf=%esp
2923   pushl %esp
2924   call trap
2925   addl $4, %esp
2926 
2927   # Return falls through to trapret...
2928 .globl trapret
2929 trapret:
2930   popal
2931   popl %gs
2932   popl %fs
2933   popl %es
2934   popl %ds
2935   addl $0x8, %esp  # trapno and errcode
2936   iret
2937 
2938 
2939 
2940 
2941 
2942 
2943 
2944 
2945 
2946 
2947 
2948 
2949 
